import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { OrderEntity } from './order.entity';

@Entity('shop-order-item')
export class OrderItemEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '订单id' })
  orderId: number;

  @ManyToOne(() => OrderEntity, (order) => order.items)
  @JoinColumn({ name: 'orderId' })
  order: OrderEntity;

  @Column({ comment: '商品id' })
  productId: number;

  @Column({ comment: '商品名称' })
  productName: string;

  @Column('decimal', { precision: 10, scale: 2, comment: '价格' })
  price: number;

  @Column({ comment: '购买数量' })
  quantity: number;

  @Column({ nullable: true, comment: '商品图片' })
  image: string;
}
